
cmake_minimum_required(VERSION 2.6)

project(enet)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_CURRENT_BINARY_DIR bin)

set(enet_SRCS
  callbacks.c
  compress.c
  host.c
  list.c
  packet.c
  peer.c
  protocol.c
  unix.c
  win32.c
)

# Configure config.h
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckStructMember)
include(CheckType)

check_function_exists(gethostbyaddr_r HAS_GETHOSTBYADDR_R)
check_function_exists(gethostbyname_r HAS_GETHOSTBYNAME_R)
check_function_exists(poll HAS_POLL)
check_function_exists(fcntl HAS_FCNTL)
check_function_exists(inet_pton HAS_INET_PTON)
check_function_exists(inet_ntop HAS_INET_NTOP)

check_struct_member(msghdr msg_flags "sys/socket.h" HAS_MDGHDR_FLAGS)
check_type(socklen_t "sys/socket.h" HAS_SOCKLEN_T)

configure_file(config.h.in config.h)

include_directories(include)

add_library(enet STATIC ${enet_SRCS})
